//
//  LOLHerodetaiViewController.m
//  LOLXXbox
//
//  Created by mac on 16/2/27.
//  Copyright © 2016年 Grasstrio. All rights reserved.
//

#import "LOLHerodetaiViewController.h"
#import <UIImageView+WebCache.h>
#import "LOLBasebutton.h"
#import <MBProgressHUD.h>
#import "LSZNetWorkTools.h"
#import "LOLDetailheroModel.h"
#import "LOLinformationTabCell.h"
#import <UIButton+WebCache.h>
#import "LOLusekillTableViewCell.h"
#import "LOLlikeandTableViewCell.h"
#import "LSZDataBaseSinglenton.h"
#import "LOLequipModel.h"
#import <UIImageView+WebCache.h>
#import "LOLFitCellHeight.h"
#import "LOLEquipCollectionCell.h"
#import "LOLequipTableViewCell.h"
#import "LOLequVCViewController.h"
#import <MJRefresh.h>
#import "LOLVideoXTableViewCell.h"
#import "LOLVideoXModel.h"
#import "LOLMvPlayerViewController.h"
#import "LOLmvplayerModel.h"
#import "LOLHeroTableViewCell.h"
#import "LOLFuwenViewController.h"
#import "LOLWebViewController.h"
#import "LOLimageViewController.h"
#import "LOLversionViewController.h"
#define TOPCHOOSEHEIGHT 30
#define TOPHEIGHT 64
#define BOTTOMHEIGHT 49
#define OTHERDUBNameURL @"http://box.dwstatic.com/apiHeroSound.php?hero=Common"

#define WIDTH [[UIScreen mainScreen]bounds].size.width
#define HEIGHT [[UIScreen mainScreen]bounds].size.height
#define HEROHEADURL(name) [NSString stringWithFormat:@"http://img.lolbox.duowan.com/champions/%@_120x120.jpg",name]
#define DETAILHEROURL(name)  [[NSString stringWithFormat:@"http://lolbox.duowan.com/phone/apiHeroDetail.php?heroName=%@", name] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
#define NBUSERURL(name) [NSString stringWithFormat:@"http://lolbox.duowan.com/phone/heroTop10PlayersNew.php?hero=%@",name]
#define SKILLIMAGEURLSIGNLE(name) [NSString stringWithFormat:@"http://img.lolbox.duowan.com/abilities/%@_64x64.png",name]
#define HEROEQUIP(name) [NSString stringWithFormat:@"http://db.duowan.com/lolcz/img/ku11/api/lolcz.php?championName=%@&limit=7",name]
#define VIDEOURL(page,name)  [NSString stringWithFormat:@"http://box.dwstatic.com/apiVideoesNormalDuowan.php?action=l&p=%@&tag=%@",page,name]
#define VIDEODETAILURL(vid) [NSString stringWithFormat:@"http://box.dwstatic.com/apiVideoesNormalDuowan.php?action=f&vid=%@",vid]
#define VIDEODETAILURL(vid) [NSString stringWithFormat:@"http://box.dwstatic.com/apiVideoesNormalDuowan.php?action=f&vid=%@",vid]
#define HERODUBNAMEURL(name) [NSString stringWithFormat:@"http://box.dwstatic.com/apiHeroSound.php?hero=%@",name]

#define MUSICPATH [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0] stringByAppendingPathComponent:@"musicInfo.plist"]
#define MUSICFILEPATH [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0] stringByAppendingPathComponent:@"music"]

#define VIDEODETAILURL(vid) [NSString stringWithFormat:@"http://box.dwstatic.com/apiVideoesNormalDuowan.php?action=f&vid=%@",vid]

#define HEROCOMMENTURL(name) [NSString stringWithFormat:@"http://comment3.duowan.com/index.php?r=phone/index&domain=lolbox.duowan.com&url=/heroDetail/%@&assest",name]

typedef NS_ENUM(NSUInteger, skillId)
{
    skill_B,
    skill_Q,
    skill_W,
    skill_E,
    skill_R,
    
    
};
@interface LOLHerodetaiViewController ()<UITableViewDataSource,UITableViewDelegate,UIWebViewDelegate>
@property(nonatomic,copy)NSArray *rightItemArr;//导航栏右侧展开按钮
@property(nonatomic,retain)UITableView *rightItemTableView; //导航栏右侧展开TableView
@property(nonatomic,retain)UIImageView *headImageView;
@property(nonatomic,retain)UILabel *cnNameLabel;
@property(nonatomic,retain)UILabel *typeLabel;
@property(nonatomic,retain)UILabel *priceLabel;
@property(nonatomic,retain)UILabel *propertyLabel;
@property(nonatomic,assign)BOOL isCollected;
@property(nonatomic,retain)LOLBasebutton *collectButton;
@property(nonatomic,retain)LOLBasebutton *heroPKbutton;//对比
@property(nonatomic,retain)LOLBasebutton *propertyButton;//符文
@property(nonatomic,retain)MBProgressHUD *hud;
@property(nonatomic,retain)LOLDetailheroModel *detailModel;
//选择按钮
@property(nonatomic,retain)UITableView *dataTableView;
@property(nonatomic,retain)UIWebView *NBUserWebView;
@property(nonatomic,retain)UITableView *equipTableView;
@property(nonatomic,retain)UITableView *videoTableView;
@property(nonatomic,retain)UITableView *dubTableView;
@property(nonatomic,retain)NSMutableURLRequest *request;
// 资料
@property(nonatomic,retain)UIView *headView;
@property(nonatomic,retain)UILabel *nameLabel;
@property(nonatomic,retain)UILabel *descriptionsDetailLabel;
@property(nonatomic,retain)UILabel *cooldownDetailLabel;
@property(nonatomic,retain)UILabel *costDetailLabel;
@property(nonatomic,retain)UILabel *rangeDetailLabel;
@property(nonatomic,retain)UILabel *effectDetailLabel;
@property(nonatomic,retain)UILabel *descriptionsLabel;
@property(nonatomic,retain)UILabel *cooldownLabel;
@property(nonatomic,retain)UILabel *costLabel;
@property(nonatomic,retain)UILabel *rangeLabel;
@property(nonatomic,retain)UILabel *effectLabel;
@property(nonatomic,copy)void(^setButtonBlock)();
@property(nonatomic,assign)BOOL isHeroDub;

@property(nonatomic,retain)NSMutableArray *equipArr; // 装备数组
@property(nonatomic,retain)NSMutableArray *modelArr;
@property(nonatomic,retain)NSMutableArray *heroDubNameArr;

@property(nonatomic,retain)NSMutableArray *videoModelArr; // 视频的数组

@property(nonatomic,retain)NSMutableArray *dubNameArr;
@property(nonatomic,retain)NSMutableArray *otherDubNameArr;

@end

@implementation LOLHerodetaiViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(pushToSelfPage:) name:@"enName" object:nil];
    

    self.equipArr = [NSMutableArray array];
    [self createDataTableView];//资料页面
    [self getData]; //网络请求
    [self getEquipData];
    [self createHeroData];
    [self createDubData];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = self.heroModel.title;
    
    [self createTopChooseButton]; //创建五个选个按钮
    [self creatheadView]; // 头视图
    [self creatNavrightView]; // 导航栏右侧TableView
  
    // 装备页面
    [self createNBUserView];
    [self createDubTableView];
    [self createVideoTableView];
    [self createEquipTableView];
    self.videoTableView.hidden = YES;
    self.NBUserWebView.hidden = YES;
    self.equipTableView.hidden = YES;
    self.dubTableView.hidden = YES;
    
  
    self.page = 2;

    [self createVideoData:@"1"];
    
}



// 创建导航栏右侧按钮视图
- (void)creatNavrightView {
    self.rightItemArr = @[@"评论",@"皮肤",@"英雄改动",@"分享"];
    self.navigationItem.rightBarButtonItem=[[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"more"] style:UIBarButtonItemStyleDone target:self action:@selector(rightItemClick:)];
    self.rightItemTableView=[[UITableView alloc]initWithFrame:CGRectMake(WIDTH-WIDTH/4, 0, WIDTH/4, 180) style:UITableViewStylePlain];
    self.rightItemTableView.delegate = self;
    self.rightItemTableView.dataSource = self;
    self.rightItemTableView.hidden = YES;
    self.rightItemTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.view addSubview:self.rightItemTableView];

}
// 创建Top视图
- (void)creatheadView {
    self.headImageView = [[UIImageView alloc]initWithFrame:CGRectMake(8, 5, 81, 81)];
    [self.headImageView sd_setImageWithURL:[NSURL URLWithString:HEROHEADURL(self.heroModel.enName)] placeholderImage:[UIImage imageNamed:@"placeholder"]];
    [self.view addSubview:self.headImageView];
    
    self.cnNameLabel = [[UILabel alloc]initWithFrame:CGRectMake(95, 10, 80, 25)];
    self.cnNameLabel.font = [UIFont systemFontOfSize:16 weight:2];
    [self.view addSubview:self.cnNameLabel];
    
    
    self.typeLabel = [[UILabel alloc]initWithFrame:CGRectMake(165, 10, 40, 25)];
    self.typeLabel.layer.cornerRadius = 10;
    self.typeLabel.textColor = [UIColor whiteColor];
    self.typeLabel.font = [UIFont systemFontOfSize:15];
    self.typeLabel.backgroundColor = [UIColor colorWithRed:0.097 green:0.548 blue:1.000 alpha:0.900];
    self.typeLabel.textAlignment = NSTextAlignmentCenter;
    
    
    self.priceLabel = [[UILabel alloc]initWithFrame:CGRectMake(95, 40, 120, 20)];
    self.priceLabel.textColor = [UIColor grayColor];
    self.priceLabel.font = [UIFont systemFontOfSize:14];
    [self.view addSubview:self.priceLabel];
    
    
    self.propertyLabel = [[UILabel alloc]initWithFrame:CGRectMake(95, 65, 130, 20)];
    self.propertyLabel.textColor = [UIColor grayColor];
    self.propertyLabel.font = [UIFont systemFontOfSize:14];
    [self.view addSubview:self.propertyLabel];
    

    self.collectButton = [LOLBasebutton baseButtonFrame:CGRectMake(210, 10, 25, 25) buttonType:UIButtonTypeCustom buttonTitle:nil buttonTitleColor:nil buttonTag:0 buttonImage:[UIImage imageNamed:@"nolight"]];
    [self.collectButton addTarget:self action:@selector(clickCollectButton:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.collectButton];
    

    
    
    self.propertyButton = [LOLBasebutton baseButtonFrame:CGRectMake(WIDTH-80, 35, 60, 35) buttonType:UIButtonTypeSystem buttonTitle:@"天赋符文" buttonTitleColor:[UIColor whiteColor] buttonTag:0 buttonImage:nil];
    self.propertyButton.backgroundColor = [UIColor colorWithRed:0.095 green:0.735 blue:1.000 alpha:0.870];
    self.propertyButton.layer.cornerRadius = 8;
    [self.propertyButton addTarget:self action:@selector(clickPropertyButton:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.propertyButton];
    
    
    
}

-(void)clickPropertyButton:(UIButton *)button
{
    
    LOLFuwenViewController *gfVC=[[LOLFuwenViewController alloc]init];
    gfVC.enName=self.detailModel.name;
    [self.navigationController pushViewController:gfVC animated:YES];


    
    
}


- (void)clickCollectButton:(UIButton *)sender {
    NSMutableArray *array  = [[LSZDataBaseSinglenton shareDataBase]selectDataBasearray];
    if ([array[2] containsObject:self.heroModel.enName]) {
        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"" message:@"已经收藏过了" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:@"取消", nil];
        [alert show];
    }else{
        [[LSZDataBaseSinglenton shareDataBase]insertDataBase:HEROHEADURL(self.heroModel.enName) withTitle:self.heroModel.cnName withImageurl:self.heroModel.enName];
        UIAlertView *alertView=[[UIAlertView alloc]initWithTitle:@"提示" message:@"收藏成功" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:@"取消", nil];
        [alertView show];


    }
    

}


- (void)rightItemClick:(UIButton *)sender {
    self.rightItemTableView.hidden=!self.rightItemTableView.hidden;
    [self.rightItemTableView bringSubviewToFront:self.view];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (tableView==self.rightItemTableView)
    {
        static NSString *reuse = @"rightItemReuse";
        UITableViewCell *cell =  [tableView dequeueReusableCellWithIdentifier:reuse];
        if (!cell) {
            cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuse];
            cell.textLabel.textAlignment=NSTextAlignmentCenter;
            cell.textLabel.textColor=[UIColor whiteColor];
            cell.textLabel.font=[UIFont systemFontOfSize:12];
            
        }
        cell.backgroundColor=[UIColor orangeColor];
        cell.textLabel.text=self.rightItemArr[indexPath.row];
        return cell;
        
    }
    
    else if(tableView == self.videoTableView){
        static NSString *reuse = @"heroVideoReuse";
        LOLVideoXTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuse];
        if (!cell) {
            cell = [[LOLVideoXTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuse];
        }
        LOLVideoXModel *videoModel = self.videoModelArr[indexPath.row];
       
        [cell.videoImageView sd_setImageWithURL:[NSURL URLWithString:videoModel.cover_url] placeholderImage:[UIImage imageNamed:@"placeholder"]];
        cell.videoTitleLabel.text = videoModel.title;
        
        NSInteger hour = videoModel.video_length.integerValue/60/60;
        NSInteger minute = videoModel.video_length.integerValue/60-hour;
        NSInteger second = videoModel.video_length.integerValue%60;
        
        cell.videoTime.text = [NSString stringWithFormat:@"%ld:%02ld:%02ld",hour,minute,second];
        cell.videoDate.text = [videoModel.upload_time substringWithRange:NSMakeRange(5, 5)];
        
        return cell;

    
    }
    
    else if (tableView == self.dubTableView){
        
        static NSString *reuse = @"heroDubReuse";
        LOLHeroTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuse];
        if (!cell) {
            cell = [[LOLHeroTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuse];
        }
        NSString *str = self.dubNameArr[indexPath.row];
        
        if (self.isHeroDub) {
            if ([str hasPrefix:[NSString stringWithFormat:@"%@_",self.heroModel.enName]]) {
                cell.dubNameLabel.text = [str substringWithRange:NSMakeRange(self.heroModel.enName.length+1, str.length-4-self.heroModel.enName.length-1)];
            }
            else
            {
                cell.dubNameLabel.text = [str substringToIndex:str.length-5];
                
            }
        }
        else
        {
            cell.dubNameLabel.text = [str substringWithRange:NSMakeRange(7 ,str.length-4-7)];
        }
        
        
        return cell;
        
        
        
        
    }

    
    
    
    
    
    else if (tableView == self.equipTableView) {
        
        
        static NSString *reuse = @"HreoEquipReuse";
        LOLequipTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuse];
        if (!cell) {
            cell = [[LOLequipTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuse];
        }
        LOLequipModel *equipModel =  self.equipArr[indexPath.row];
        NSArray *equipImageArr = [equipModel.end_cz componentsSeparatedByString:@","];
        
        cell.imageIdArr=equipImageArr;
        
        
        
        
        cell.titleNameLabel.text = equipModel.title;
        cell.userInfoLabel.text = [NSString stringWithFormat:@"%@ %@ ☼%@",equipModel.server,equipModel.author,equipModel.combat];
        
        
        
        return cell;
    }

    
    
    
    else if (tableView==self.dataTableView){
        static NSString *reuse = @"HreoSliderDataReuse";
        if (indexPath.row==0){
            LOLinformationTabCell *cell =  [tableView dequeueReusableCellWithIdentifier:reuse];
            if (!cell) {
                cell = [[LOLinformationTabCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuse];
            }
            
            cell.detailModel=self.detailModel;
            cell.levelLabel.text = @"1";
            cell.attackLabel.text = self.detailModel.range;
            cell.speedLabel.text = self.detailModel.moveSpeed;
            
            cell.baseAttackLabel.text = [NSString stringWithFormat:@"%0.2f (%@/每级)",self.detailModel.attackBase.floatValue+self.detailModel.attackLevel.floatValue,self.detailModel.attackLevel];
            
            cell.baseDefenseLabel.text = [NSString stringWithFormat:@"%0.2f (%@/每级)",self.detailModel.armorBase.floatValue+self.detailModel.armorLevel.floatValue,self.detailModel.armorLevel];
            
            cell.baseMagicLabel.text = [NSString stringWithFormat:@"%0.2f (%@/每级)",self.detailModel.manaBase.floatValue+self.detailModel.manaLevel.floatValue,self.detailModel.manaLevel];
            
            cell.baseHealthLabel.text = [NSString stringWithFormat:@"%0.2f (%@/每级)",self.detailModel.healthBase.floatValue+self.detailModel.healthLevel.floatValue,self.detailModel.healthLevel];
            
            cell.crushLabel.text = [NSString stringWithFormat:@"%0.2f (%@/每级)",self.detailModel.criticalChanceBase.floatValue+self.detailModel.criticalChanceLevel.floatValue,self.detailModel.criticalChanceLevel];
            
            cell.magicRecoverLabel.text=[NSString stringWithFormat:@"%0.2f (%@/每级)",self.detailModel.manaRegenBase.floatValue+self.detailModel.manaRegenLevel.floatValue,self.detailModel.manaRegenLevel];
            
            cell.healthRecoverLabel.text=[NSString stringWithFormat:@"%0.2f (%@/每级)",self.detailModel.healthRegenBase.floatValue+self.detailModel.healthRegenLevel.floatValue,self.detailModel.healthRegenLevel];
            
            cell.magicdefenseLabel.text=[NSString stringWithFormat:@"%0.2f (%@/每级)",self.detailModel.magicResistBase.floatValue+self.detailModel.magicResistLevel.floatValue,self.detailModel.magicResistLevel];
            
            
            
            
            
            return cell;
        }else if (indexPath.row==1||indexPath.row==2){
            NSArray *arr=@[@"最佳搭档",@"最佳克制"];
            static NSString *reuse = @"likeAndHateReuse";
            LOLlikeandTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:reuse];
            if (!cell) {
                cell=[[LOLlikeandTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuse];
            }
            cell.namelabel.text=arr[indexPath.row-1];
            if (indexPath.row==1&&self.detailModel.like!=nil) {
                cell.heroArr=self.detailModel.like;
                
                [cell.heroImageView1 sd_setImageWithURL:[NSURL URLWithString:HEROHEADURL(self.detailModel.like[0][@"partner"])] placeholderImage:[UIImage imageNamed:@"placeholder"]];
                [cell.heroImageView2 sd_setImageWithURL:[NSURL URLWithString:HEROHEADURL(self.detailModel.like[1][@"partner"])] placeholderImage:[UIImage imageNamed:@"placeholder"]];
                cell.heroDetailLabel1.text=self.detailModel.like[0][@"des"];
                cell.heroDetailLabel2.text=self.detailModel.like[1][@"des"];
            }
            else if (indexPath.row==2&&self.detailModel.hate!=nil){
                
                cell.heroArr=self.detailModel.hate;
                [cell.heroImageView1 sd_setImageWithURL:[NSURL URLWithString:HEROHEADURL(self.detailModel.hate[0][@"partner"])] placeholderImage:[UIImage imageNamed:@"placeholder"]];
                [cell.heroImageView2 sd_setImageWithURL:[NSURL URLWithString:HEROHEADURL(self.detailModel.hate[1][@"partner"])] placeholderImage:[UIImage imageNamed:@"placeholder"]];
                cell.heroDetailLabel1.text=self.detailModel.hate[0][@"des"];
                cell.heroDetailLabel2.text=self.detailModel.hate[1][@"des"];
                
                
            }
            else
            {
                cell.heroDetailLabel1.text=@"暂无数据";
                
            }
            
            
            
            return cell;
            

        }else if (indexPath.row==3||indexPath.row==4||indexPath.row==5) {
            NSArray *arr=@[@"使用技巧",@"应对技巧",@"英雄背景"];
            static NSString *reuse = @"useSkillsReuse";
            LOLusekillTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:reuse];
            if(!cell){
                cell=[[LOLusekillTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuse];
                
            }
            cell.namelabel.text = arr[indexPath.row-3];
            if (indexPath.row == 3)
            {
                cell.skilllabel.text=self.detailModel.tips;
            }
            else if(indexPath.row == 4)
            {
                cell.skilllabel.text=self.detailModel.opponentTips;
            }
            else
            {
                
                cell.skilllabel.text=self.detailModel.descriptionss;
                
            }
            return cell;
            
        }
        
        

        
        
        else if (tableView == self.equipTableView) {
            static NSString *reuse = @"HreoEquipReuse";
            LOLequipTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuse];
            if (!cell) {
                cell = [[LOLequipTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuse];
            }
            LOLequipModel *equipModel =  self.equipArr[indexPath.row];
            NSArray *equipImageArr = [equipModel.end_cz componentsSeparatedByString:@","];
            
            cell.imageIdArr = equipImageArr;
            cell.titleNameLabel.text = equipModel.title;
            cell.userInfoLabel.text = [NSString stringWithFormat:@"%@ %@ ☼%@",equipModel.server,equipModel.author,equipModel.combat];
            return cell;
           
        }else{
                return nil;
        }
    }
    return nil;
}

    
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (tableView==self.dataTableView) {
        if (indexPath.row==0)
        {
            return 430;
        }
        else if (indexPath.row == 1&&self.detailModel.like != nil)
        {
            CGFloat temp1=[LOLFitCellHeight computeLabelString:self.detailModel.like[0][@"des"] FontSize:15 width:WIDTH-90];
            CGFloat temp2=[LOLFitCellHeight computeLabelString:self.detailModel.like[1][@"des"] FontSize:15 width:WIDTH-90];
            
            CGFloat height1=temp1>64?temp1:64;
            CGFloat height2=temp2>64?temp2:64;
            
            return 40+height1+height2+30;
            
        }
        else if(indexPath.row==2&&self.detailModel.hate != nil)
        {
            
            CGFloat temp1=[LOLFitCellHeight computeLabelString:self.detailModel.hate[0][@"des"] FontSize:15 width:WIDTH-90];
            CGFloat temp2=[LOLFitCellHeight computeLabelString:self.detailModel.hate[1][@"des"] FontSize:15 width:WIDTH-90];
            
            CGFloat height1=temp1>64?temp1:64;
            CGFloat height2=temp2>64?temp2:64;
            
            return 40+height1+height2+30;
            
            
        }
        else if(indexPath.row == 1&&self.detailModel.like == nil)
        {
            return 70;
        }
        else if(indexPath.row == 2&&self.detailModel.hate == nil)
        {
            return 70;
        }
        
        else if(indexPath.row == 3)
        {
            return [LOLFitCellHeight computeLabelString:self.detailModel.tips FontSize:14 width:WIDTH-20]+50;
        }
        else if(indexPath.row == 4)
        {
            return [LOLFitCellHeight computeLabelString:self.detailModel.opponentTips FontSize:14 width:WIDTH-20]+50;
        }
        else if(indexPath.row == 5)
        {
            return [LOLFitCellHeight computeLabelString:self.detailModel.descriptionss FontSize:14 width:WIDTH-20]+50;
        }
        else
        {
            return 10;
            
        }
    }
    else if(tableView==self.equipTableView)
    {
         return HEIGHT/5;
    }
    else if(tableView==self.videoTableView)
    {
        return 100;
    }
    else if(tableView==self.dubTableView||tableView==self.rightItemTableView)
    {
        return 30;
        
    }
    
    else
    {
        
        return 0;
        
    }
    
}




- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if (tableView == self.dataTableView) {
        return 6;
    }
    
    else if (tableView == self.equipTableView) {
      
        return self.equipArr.count;
    
    }
    else if(tableView == self.videoTableView)
    {
     
        return self.videoModelArr.count;        
    }
    else if(tableView == self.dubTableView)
    {
        
        return self.dubNameArr.count;
        
    }
    else if(tableView == self.rightItemTableView)
    {
        return 4;
        
    }
    else
    {
        
        return 0;
    }
    

}

- (void)getData {
//    self.hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    [LSZNetWorkTools getWithUrl:DETAILHEROURL(self.heroModel.enName) parameter:nil httpHeader:nil resposeType:ResponseTypeJSON success:^(id result) {
        
        self.detailModel = [[LOLDetailheroModel alloc]init];
        [self.detailModel setValuesForKeysWithDictionary:result];
        
        [self.dataTableView reloadData];
        
        [self reFreshHeroData:skill_B];
        
        
        self.cnNameLabel.text = self.detailModel.title;
        self.navigationItem.title = self.detailModel.title;
        
        if (![self.detailModel.tags isEqualToString:@""]) {
            self.typeLabel.text = self.detailModel.tags;
            [self.view addSubview:self.typeLabel];
        }
        
        NSArray *priceArr = [self.detailModel.price componentsSeparatedByString:@","];
        NSArray *ratingArr = [self.heroModel.rating componentsSeparatedByString:@","];
        self.priceLabel.text = [NSString stringWithFormat:@"金%@,劵%@",priceArr[0],priceArr[1]];
        self.propertyLabel.text = [NSString stringWithFormat:@"功%@ 防%@ 法%@ 难度%@",ratingArr[0],ratingArr[1],ratingArr[2],ratingArr[3]];
        

    } fail:^(NSError *error) {
        
        
    }];
}

-(void)createTopChooseButton {
    
    NSArray *arr = @[@"资料",@"出装",@"视频",@"排行",@"配音"];
    for (int i  =  0; i <arr.count; i++) {
        LOLBasebutton *button = [LOLBasebutton baseButtonFrame:CGRectMake(WIDTH/arr.count*i, 100, 80, 30) buttonType:UIButtonTypeSystem buttonTitle:arr[i] buttonTitleColor:[UIColor blackColor] buttonTag:301+i buttonImage:nil];
        [button addTarget:self action:@selector(clickTopButton:) forControlEvents:UIControlEventTouchUpInside];
        button.titleLabel.font = [UIFont systemFontOfSize:14];
        [self.view addSubview:button];
        
    }
    [((UIButton *)[self.view viewWithTag:301]) setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
    ((UIButton *)[self.view viewWithTag:301]).titleLabel.font = [UIFont systemFontOfSize:15 weight:2];
    
    
    
}

-(void)clickTopButton:(LOLBasebutton *)button {
    [button setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
    button.titleLabel.font = [UIFont systemFontOfSize:15 weight:2];
    for (int i  =  0; i <5; i++) {
        if (i != button.tag%301) {
            [((UIButton *)[self.view viewWithTag:301+i]) setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
            ((UIButton *)[self.view viewWithTag:301+i]).titleLabel.font = [UIFont systemFontOfSize:14];
            
        }
    }
    switch (button.tag) {
        case 301:
            if (self.dataTableView.hidden==YES) {
                self.dataTableView.hidden =NO;
                self.NBUserWebView.hidden = YES;
                self.equipTableView.hidden = YES;
                self.videoTableView.hidden = YES;
                self.dubTableView.hidden = YES;
            }
            
            break;
        case 302:
            if (self.equipTableView.hidden==YES) {
                self.equipTableView.hidden = NO;
                self.NBUserWebView.hidden = YES;
                self.videoTableView.hidden = YES;
                self.dubTableView.hidden = YES;
                self.dataTableView.hidden =YES;
            }
            
            break;
        case 303:
            if (self.videoTableView.hidden==YES) {
                self.videoTableView.hidden = NO;
                self.NBUserWebView.hidden = YES;
                self.equipTableView.hidden = YES;
                self.dubTableView.hidden = YES;
                self.dataTableView.hidden =YES;
            }
            break;
        case 304:
            if (self.NBUserWebView.hidden==YES) {
                [self.NBUserWebView loadRequest:self.request];
                self.NBUserWebView.hidden = NO;
                self.equipTableView.hidden = YES;
                self.videoTableView.hidden = YES;
                self.dubTableView.hidden = YES;
                self.dataTableView.hidden =YES;
            }
            break;
        case 305:
            if (self.dubTableView.hidden==YES) {
                self.dubTableView.hidden = NO;
                self.NBUserWebView.hidden = YES;
                self.equipTableView.hidden = YES;
                self.videoTableView.hidden = YES;
                self.dataTableView.hidden =YES;
            }
            break;
            
            
        default:
            break;
    }
    
    
}

-(void)createEquipTableView {
    self.equipTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 150, WIDTH, self.view.frame.size.height - 150) style:UITableViewStylePlain];
    self.equipTableView.delegate = self;
    self.equipTableView.dataSource = self;
    [self.view addSubview:self.equipTableView];
}

-(void)createVideoTableView {
    self.videoTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 100+TOPCHOOSEHEIGHT, WIDTH, HEIGHT-64-49-100-TOPCHOOSEHEIGHT) style:UITableViewStylePlain];
    self.videoTableView.delegate = self;
    self.videoTableView.dataSource = self;
    [self.view addSubview:self.videoTableView];
        [self createVideoData:@"1"];
  
    
//    self.videoTableView.footer=[MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
    
        if (self.page<=self.maxPage.integerValue) {
            
            [self createVideoData:[NSString stringWithFormat:@"%ld",self.page++]];
            
        }
        else{
            
//            [self.videoTableView.footer endRefreshing];
            
        }
        
//    }];
    
    
    
    
}

-(void)createVideoData:(NSString *)page {
    [LSZNetWorkTools getWithUrl:VIDEOURL(page, self.heroModel.enName) parameter:nil httpHeader:nil resposeType:ResponseTypeJSON success:^(id result) {
    
        if ([page isEqualToString:@"1"]) {
            self.videoModelArr = [LOLVideoXModel baseModelByArr:result];

            LOLVideoXModel *videoModel=[[LOLVideoXModel alloc]init];
            [videoModel setValuesForKeysWithDictionary:result[0]];
            self.maxPage = videoModel.totalPage;
            
            
            
        }
        else{
            [self.videoModelArr addObjectsFromArray:[LOLVideoXModel baseModelByArr:result]];
//            [self.videoTableView.footer endRefreshing];
            
        }
        
        
        [self.videoTableView reloadData];
        

        
    } fail:^(NSError *error) {
        
        
    }];
  
    
    
    //
        //
        //
        //
        //
        //        self.videoModelArr = [YMH_VideoModel  baseModelByArr:result];
        //        [self.videoTableView reloadData];
        
//    } failure:^(NSError *error) {
//        
//    }];
//    
    
}





-(void)createNBUserView {
    self.NBUserWebView = [[UIWebView alloc]initWithFrame:CGRectMake(0, 100+TOPCHOOSEHEIGHT, WIDTH, HEIGHT-64-49-100-TOPCHOOSEHEIGHT)];
    self.request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:NBUSERURL(self.heroModel.enName)]];
    [self.request setValue:@"lolbox"  forHTTPHeaderField:@"Dw-Ua"];
    [self.view addSubview:self.NBUserWebView];
    self.NBUserWebView.delegate = self;
}

-(void)createDubTableView {
    self.dubTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 100+TOPCHOOSEHEIGHT, WIDTH, HEIGHT-64-49-100-TOPCHOOSEHEIGHT) style:UITableViewStylePlain];
    self.dubTableView.contentInset = UIEdgeInsetsMake(30, 0, 0, 0);
    self.dubTableView.delegate = self;
    self.dubTableView.dataSource = self;
    
    
    LOLBasebutton *heroDubButton = [LOLBasebutton baseButtonFrame:CGRectMake(10, -30,60, 30) buttonType:UIButtonTypeSystem buttonTitle:@"英雄配音" buttonTitleColor: [UIColor colorWithRed:0.260 green:0.797 blue:1.000 alpha:0.840] buttonTag:311 buttonImage:nil];
    [heroDubButton addTarget:self action:@selector(clickDubTypeButton:) forControlEvents:UIControlEventTouchUpInside];
    LOLBasebutton *otherDubButton = [LOLBasebutton baseButtonFrame:CGRectMake(80,-30, 60, 30) buttonType:UIButtonTypeSystem buttonTitle:@"其他配音" buttonTitleColor:[UIColor grayColor] buttonTag:312 buttonImage:nil];
    [otherDubButton addTarget:self action:@selector(clickDubTypeButton:) forControlEvents:UIControlEventTouchUpInside];
    
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(75, -30, 1, 30)];
    view.backgroundColor = [UIColor blackColor];
    [self.dubTableView addSubview:heroDubButton];
    [self.dubTableView addSubview:otherDubButton];
    [self.dubTableView addSubview:view];
    [self.view addSubview:self.dubTableView];
    

}

-(void)createDataTableView {
    self.dataTableView=[[UITableView alloc]initWithFrame:CGRectMake(0, 100+TOPCHOOSEHEIGHT, WIDTH, HEIGHT-TOPHEIGHT-BOTTOMHEIGHT-100-TOPCHOOSEHEIGHT) style:UITableViewStylePlain];
    self.dataTableView.delegate=self;
    self.dataTableView.dataSource=self;
    [self.view addSubview:self.dataTableView];

    
    self.headView=[[UIView alloc]init];
    UILabel *titleLabel=[[UILabel alloc]initWithFrame:CGRectMake(10, 5, WIDTH-20, 30)];
    titleLabel.font=[UIFont systemFontOfSize:16];
    titleLabel.textColor=[UIColor colorWithRed:0.254 green:0.822 blue:1.000 alpha:0.750];
    titleLabel.text=@"技能说明";
    [self.headView addSubview:titleLabel];
   
    
    NSString *str = self.heroModel.enName;
    
    NSArray *arr = @[[str stringByAppendingString:@"_B"],[str stringByAppendingString:@"_Q"],[str stringByAppendingString:@"_W"],[str stringByAppendingString:@"_E"],[str stringByAppendingString:@"_R"]];
    
    for (int i = 0; i<5; i++) {
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        button.frame = CGRectMake(10+((WIDTH-60)/5+10)*i, 35, (WIDTH-60)/5, (WIDTH-60)/5);
        [button sd_setImageWithURL:[NSURL URLWithString:SKILLIMAGEURLSIGNLE(arr[i])] forState:UIControlStateNormal];
        button.tag = 601+i;
        [button addTarget:self action:@selector(chooseSkillDisPlay:) forControlEvents:UIControlEventTouchUpInside];
        button.alpha=0.5;
        [self.headView addSubview:button];
    }
    ((UIButton *)[self.headView viewWithTag:601]).alpha=1;
    
    
    
    
//    self.singelLineView=[[YMH_singelLineView alloc]initWithPoint:CGPointZero xOry:1 lineLength:WIDTH-20 lineColor:[UIColor colorWithWhite:0.500 alpha:0.310]];
//    [self.headView addSubview:self.singelLineView];
//    [_singelLineView release];
    
    self.nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 30+10+(WIDTH-60)/5, WIDTH-20, 20)];
    self.nameLabel.font=[UIFont systemFontOfSize:15];
    [self.headView addSubview:self.nameLabel];

    
    self.descriptionsLabel=[[UILabel alloc]init];
    self.descriptionsLabel.text=@"描述";
    self.descriptionsLabel.font=[UIFont systemFontOfSize:13];
    self.descriptionsLabel.textColor=[UIColor grayColor];
    [self.headView addSubview:self.descriptionsLabel];

    
    
    self.costLabel=[[UILabel alloc]init];
    self.costLabel.text=@"消耗";
    self.costLabel.font=[UIFont systemFontOfSize:13];
    self.costLabel.textColor=[UIColor grayColor];
    [self.headView addSubview:self.costLabel];

    
    self.cooldownLabel=[[UILabel alloc]init];
    self.cooldownLabel.text=@"冷却";
    self.cooldownLabel.font=[UIFont systemFontOfSize:13];
    self.cooldownLabel.textColor=[UIColor grayColor];
    [self.headView addSubview:self.cooldownLabel];

    
    self.rangeLabel=[[UILabel alloc]init];
    self.rangeLabel.text=@"范围";
    self.rangeLabel.font=[UIFont systemFontOfSize:13];
    self.rangeLabel.textColor=[UIColor grayColor];
    [self.headView addSubview:self.rangeLabel];

    
    self.effectLabel=[[UILabel alloc]init];
    self.effectLabel.text=@"效果";
    self.effectLabel.font=[UIFont systemFontOfSize:13];
    self.effectLabel.textColor=[UIColor grayColor];
    [self.headView addSubview:self.effectLabel];

    
    
    self.descriptionsDetailLabel=[[UILabel alloc]init];
    [self.headView addSubview:self.descriptionsDetailLabel];

    
    self.cooldownDetailLabel=[[UILabel alloc]init];
    [self.headView addSubview:self.cooldownDetailLabel];

    self.costDetailLabel=[[UILabel alloc]init];
    [self.headView addSubview:self.costDetailLabel];
    

    self.rangeDetailLabel=[[UILabel alloc]init];
    [self.headView addSubview:self.rangeDetailLabel];

    
    self.effectDetailLabel=[[UILabel alloc]init];
    [self.headView addSubview:self.effectDetailLabel];

    
    
    self.descriptionsDetailLabel.font=[UIFont systemFontOfSize:14];
    self.cooldownDetailLabel.font=[UIFont systemFontOfSize:14];
    self.costDetailLabel.font=[UIFont systemFontOfSize:14];
    self.rangeDetailLabel.font=[UIFont systemFontOfSize:14];
    self.effectDetailLabel.font=[UIFont systemFontOfSize:14];
    
    self.descriptionsDetailLabel.numberOfLines=0;
    self.cooldownDetailLabel.numberOfLines=0;
    self.costDetailLabel.numberOfLines=0;
    self.rangeDetailLabel.numberOfLines=0;
    self.effectDetailLabel.numberOfLines=0;

    
}

-(void)reFreshHeroData:(skillId)skillId {
    
    
    CGFloat temp = 30+10+(WIDTH-60)/5+20+5;
    
    
    CGFloat descriptionHeight =20;
    CGFloat costHeight = 20;
    CGFloat cooldownHeight = 20;
    CGFloat rangeHeight = 20;
    CGFloat effectHeight = 20;
    
    
    switch (skillId) {
        case skill_B:
            self.nameLabel.text = [self.detailModel.skillB[@"name"] stringByAppendingString:@"(被动)"];
            descriptionHeight = [LOLFitCellHeight computeLabelString:self.detailModel.skillB[@"description"] FontSize:14 width:WIDTH-45-10];
            costHeight = [LOLFitCellHeight computeLabelString:self.detailModel.skillB[@"cost"] FontSize:14 width:WIDTH-45-10];
            cooldownHeight = [LOLFitCellHeight computeLabelString:self.detailModel.skillB[@"cooldown"] FontSize:14 width:WIDTH-45-10];
            rangeHeight = [LOLFitCellHeight computeLabelString:self.detailModel.skillB[@"range"] FontSize:14 width:WIDTH-45-10];
            effectHeight = [LOLFitCellHeight computeLabelString:self.detailModel.skillB[@"effect"] FontSize:14 width:WIDTH-45-10];
            if ([self.detailModel.skillB[@"description"] isEqualToString:@""]) {
                self.descriptionsDetailLabel.text=@"无";
            }
            else
            {
                self.descriptionsDetailLabel.text=self.detailModel.skillB[@"description"];
                
            }
            if ([self.detailModel.skillB[@"cooldown"] isEqualToString:@""]) {
                self.cooldownDetailLabel.text=@"无";
            }
            else
            {
                self.cooldownDetailLabel.text=self.detailModel.skillB[@"cooldown"];
                
            }
            
            if ([self.detailModel.skillB[@"cost"] isEqualToString:@""]) {
                self.costDetailLabel.text=@"无";
            }
            else
            {
                self.costDetailLabel.text=self.detailModel.skillB[@"cost"];
                
            }
            
            if ([self.detailModel.skillB[@"range"] isEqualToString:@""]) {
                self.rangeDetailLabel.text=@"无";
            }
            else
            {
                self.rangeDetailLabel.text=self.detailModel.skillB[@"range"];
                
            }
            
            if ([self.detailModel.skillB[@"effect"] isEqualToString:@""]) {
                self.effectDetailLabel.text=@"无";
            }
            else
            {
                self.effectDetailLabel.text=self.detailModel.skillB[@"effect"];
                
            }
            
            break;
        case skill_Q:
            self.nameLabel.text=[self.detailModel.skillQ[@"name"] stringByAppendingString:@"(Q)"];
            descriptionHeight = [LOLFitCellHeight computeLabelString:self.detailModel.skillQ[@"description"] FontSize:14 width:WIDTH-45-10];
            costHeight = [LOLFitCellHeight computeLabelString:self.detailModel.skillQ[@"cost"] FontSize:14 width:WIDTH-45-10];
            cooldownHeight = [LOLFitCellHeight computeLabelString:self.detailModel.skillQ[@"cooldown"] FontSize:14 width:WIDTH-45-10];
            rangeHeight = [LOLFitCellHeight computeLabelString:self.detailModel.skillQ[@"range"] FontSize:14 width:WIDTH-45-10];
            effectHeight = [LOLFitCellHeight computeLabelString:self.detailModel.skillQ[@"effect"] FontSize:14 width:WIDTH-45-10];
            if ([self.detailModel.skillQ[@"description"] isEqualToString:@""]) {
                self.descriptionsDetailLabel.text=@"无";
            }
            else
            {
                self.descriptionsDetailLabel.text=self.detailModel.skillQ[@"description"];
                
            }
            if ([self.detailModel.skillQ[@"cooldown"] isEqualToString:@""]) {
                self.cooldownDetailLabel.text=@"无";
            }
            else
            {
                self.cooldownDetailLabel.text=self.detailModel.skillQ[@"cooldown"];
                
            }
            
            if ([self.detailModel.skillQ[@"cost"] isEqualToString:@""]) {
                self.costDetailLabel.text=@"无";
            }
            else
            {
                self.costDetailLabel.text=self.detailModel.skillQ[@"cost"];
                
            }
            
            if ([self.detailModel.skillQ[@"range"] isEqualToString:@""]) {
                self.rangeDetailLabel.text=@"无";
            }
            else
            {
                self.rangeDetailLabel.text=self.detailModel.skillQ[@"range"];
                
            }
            
            if ([self.detailModel.skillQ[@"effect"] isEqualToString:@""]) {
                self.effectDetailLabel.text=@"无";
            }
            else
            {
                self.effectDetailLabel.text=self.detailModel.skillQ[@"effect"];
                
            }
            
            break;
        case skill_W:
            self.nameLabel.text=[self.detailModel.skillW[@"name"] stringByAppendingString:@"(W)"];
            descriptionHeight = [LOLFitCellHeight computeLabelString:self.detailModel.skillW[@"description"] FontSize:14 width:WIDTH-45-10];
            costHeight = [LOLFitCellHeight computeLabelString:self.detailModel.skillW[@"cost"] FontSize:14 width:WIDTH-45-10];
            cooldownHeight = [LOLFitCellHeight computeLabelString:self.detailModel.skillW[@"cooldown"] FontSize:14 width:WIDTH-45-10];
            rangeHeight = [LOLFitCellHeight computeLabelString:self.detailModel.skillW[@"range"] FontSize:14 width:WIDTH-45-10];
            effectHeight = [LOLFitCellHeight computeLabelString:self.detailModel.skillW[@"effect"] FontSize:14 width:WIDTH-45-10];
            if ([self.detailModel.skillW[@"description"] isEqualToString:@""]) {
                self.descriptionsDetailLabel.text=@"无";
            }
            else
            {
                self.descriptionsDetailLabel.text=self.detailModel.skillW[@"description"];
                
            }
            if ([self.detailModel.skillW[@"cooldown"] isEqualToString:@""]) {
                self.cooldownDetailLabel.text=@"无";
            }
            else
            {
                self.cooldownDetailLabel.text=self.detailModel.skillW[@"cooldown"];
                
            }
            
            if ([self.detailModel.skillW[@"cost"] isEqualToString:@""]) {
                self.costDetailLabel.text=@"无";
            }
            else
            {
                self.costDetailLabel.text=self.detailModel.skillW[@"cost"];
                
            }
            
            if ([self.detailModel.skillW[@"range"] isEqualToString:@""]) {
                self.rangeDetailLabel.text=@"无";
            }
            else
            {
                self.rangeDetailLabel.text=self.detailModel.skillW[@"range"];
                
            }
            
            if ([self.detailModel.skillW[@"effect"] isEqualToString:@""]) {
                self.effectDetailLabel.text=@"无";
            }
            else
            {
                self.effectDetailLabel.text=self.detailModel.skillW[@"effect"];
                
            }
            
            break;
        case skill_E:
            self.nameLabel.text=[self.detailModel.skillE[@"name"] stringByAppendingString:@"(E)"];
            descriptionHeight = [LOLFitCellHeight computeLabelString:self.detailModel.skillE[@"description"] FontSize:14 width:WIDTH-45-10];
            costHeight = [LOLFitCellHeight computeLabelString:self.detailModel.skillE[@"cost"] FontSize:14 width:WIDTH-45-10];
            cooldownHeight = [LOLFitCellHeight computeLabelString:self.detailModel.skillE[@"cooldown"] FontSize:14 width:WIDTH-45-10];
            rangeHeight = [LOLFitCellHeight computeLabelString:self.detailModel.skillE[@"range"] FontSize:14 width:WIDTH-45-10];
            effectHeight = [LOLFitCellHeight computeLabelString:self.detailModel.skillE[@"effect"] FontSize:14 width:WIDTH-45-10];
            if ([self.detailModel.skillE[@"description"] isEqualToString:@""]) {
                self.descriptionsDetailLabel.text=@"无";
            }
            else
            {
                self.descriptionsDetailLabel.text=self.detailModel.skillE[@"description"];
                
            }
            if ([self.detailModel.skillE[@"cooldown"] isEqualToString:@""]) {
                self.cooldownDetailLabel.text=@"无";
            }
            else
            {
                self.cooldownDetailLabel.text=self.detailModel.skillE[@"cooldown"];
                
            }
            
            if ([self.detailModel.skillE[@"cost"] isEqualToString:@""]) {
                self.costDetailLabel.text=@"无";
            }
            else
            {
                self.costDetailLabel.text=self.detailModel.skillE[@"cost"];
                
            }
            
            if ([self.detailModel.skillE[@"range"] isEqualToString:@""]) {
                self.rangeDetailLabel.text=@"无";
            }
            else
            {
                self.rangeDetailLabel.text=self.detailModel.skillE[@"range"];
                
            }
            
            if ([self.detailModel.skillE[@"effect"] isEqualToString:@""]) {
                self.effectDetailLabel.text=@"无";
            }
            else
            {
                self.effectDetailLabel.text=self.detailModel.skillE[@"effect"];
                
            }
            
            break;
        case skill_R:
            self.nameLabel.text=[self.detailModel.skillR[@"name"] stringByAppendingString:@"(R)"];
            descriptionHeight = [LOLFitCellHeight computeLabelString:self.detailModel.skillR[@"description"] FontSize:14 width:WIDTH-45-10];
            costHeight = [LOLFitCellHeight computeLabelString:self.detailModel.skillR[@"cost"] FontSize:14 width:WIDTH-45-10];
            cooldownHeight = [LOLFitCellHeight computeLabelString:self.detailModel.skillR[@"cooldown"] FontSize:14 width:WIDTH-45-10];
            rangeHeight = [LOLFitCellHeight computeLabelString:self.detailModel.skillR[@"range"] FontSize:14 width:WIDTH-45-10];
            effectHeight = [LOLFitCellHeight computeLabelString:self.detailModel.skillR[@"effect"] FontSize:14 width:WIDTH-45-10];
            if ([self.detailModel.skillR[@"description"] isEqualToString:@""]) {
                self.descriptionsDetailLabel.text=@"无";
            }
            else
            {
                self.descriptionsDetailLabel.text=self.detailModel.skillR[@"description"];
                
            }
            if ([self.detailModel.skillR[@"cooldown"] isEqualToString:@""]) {
                self.cooldownDetailLabel.text=@"无";
            }
            else
            {
                self.cooldownDetailLabel.text=self.detailModel.skillR[@"cooldown"];
                
            }
            
            if ([self.detailModel.skillR[@"cost"] isEqualToString:@""]) {
                self.costDetailLabel.text=@"无";
            }
            else
            {
                self.costDetailLabel.text=self.detailModel.skillR[@"cost"];
                
            }
            
            if ([self.detailModel.skillR[@"range"] isEqualToString:@""]) {
                self.rangeDetailLabel.text=@"无";
            }
            else
            {
                self.rangeDetailLabel.text=self.detailModel.skillR[@"range"];
                
            }
            
            if ([self.detailModel.skillR[@"effect"] isEqualToString:@""]) {
                self.effectDetailLabel.text=@"无";
            }
            else
            {
                self.effectDetailLabel.text=self.detailModel.skillR[@"effect"];
                
            }
            
            break;
            
        default:
            break;
    }
    
    
    
    
    
    self.descriptionsDetailLabel.frame = CGRectMake(45, temp, WIDTH-45-10, descriptionHeight);
    
    self.cooldownDetailLabel.frame = CGRectMake(45, temp+descriptionHeight+10+2, WIDTH-45-10, cooldownHeight);
    
    self.costDetailLabel.frame=CGRectMake(45, temp+descriptionHeight+cooldownHeight+10*2+2, WIDTH-45-10,costHeight);
    
    self.rangeDetailLabel.frame = CGRectMake(45, temp+descriptionHeight+costHeight+cooldownHeight+10*3+2, WIDTH-45-10, rangeHeight);
    
    self.effectDetailLabel.frame = CGRectMake(45, temp+descriptionHeight+costHeight+rangeHeight+cooldownHeight+10*4+2, WIDTH-45-10, effectHeight);
    
    
    
    
    
    
    
    
    self.descriptionsLabel.frame = CGRectMake(10, temp, 30,20);
    
    self.cooldownLabel.frame = CGRectMake(10, temp+descriptionHeight+10,30,20);
    
    self.costLabel.frame=CGRectMake(10, temp+descriptionHeight+cooldownHeight+10*2, 30,20);
    
    self.rangeLabel.frame = CGRectMake(10, temp+descriptionHeight+costHeight+cooldownHeight+10*3, 30,20);
    
    self.effectLabel.frame = CGRectMake(10, temp+descriptionHeight+costHeight+rangeHeight+cooldownHeight+10*4,30,20);
    
    
    
//    self.singelLineView.frame=CGRectMake(10, temp+descriptionHeight+costHeight+cooldownHeight+rangeHeight+effectHeight+63, WIDTH-20, 1);
    
    self.headView.frame=CGRectMake(0, 0,WIDTH, temp+descriptionHeight+costHeight+cooldownHeight+rangeHeight+effectHeight+65);
    
    self.dataTableView.tableHeaderView=self.headView;
    
    
    
}

-(void)createHeroData {
    NSString *sanboxPath=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask , YES)[0];
    NSString *documentPath=[sanboxPath stringByAppendingPathComponent:@"allHero.test"];
    self.modelArr = [NSKeyedUnarchiver unarchiveObjectWithFile:documentPath];
    
}

-(void)chooseSkillDisPlay:(UIButton *)button
{
    
    
    for (int i=0; i<5; i++) {
        
        if(i+601 != button.tag)
        {
            ((UIButton *)[self.headView viewWithTag:601+i]).alpha=0.5;
        }
        else
        {
            button.alpha=1;
            
        }
    }
    
    
    switch (button.tag) {
        case 601:
            [self reFreshHeroData:skill_B];
            break;
        case 602:
            [self reFreshHeroData:skill_Q];
            break;
            
        case 603:
            [self reFreshHeroData:skill_W];
            break;
            
        case 604:
            [self reFreshHeroData:skill_E];
            break;
            
        case 605:
            [self reFreshHeroData:skill_R];
            break;
            
            
        default:
            break;
    }
    
    
}


-(void)getEquipData{
  [LSZNetWorkTools getWithUrl:HEROEQUIP(self.heroModel.enName) parameter:nil httpHeader:nil resposeType:ResponseTypeJSON success:^(id result) {
      self.equipArr = [LOLequipModel baseModelByArr:result];
      [self.equipTableView reloadData];
      
  } fail:^(NSError *error) {
      
      
  }];
    
    
    
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    if (tableView == self.equipTableView) {
        LOLequipModel *model1 = self.equipArr[indexPath.row];
        
        LOLequipModel *(^block1)() = ^(){
            
            return model1;
        };
        
        LOLDetailheroModel *(^block2)() = ^(){
            
            return self.detailModel;
            
        };

        

        LOLequVCViewController *geVC = [[LOLequVCViewController alloc]init];
        geVC.equipDetailBlock = block1;
        geVC.detailBlock = block2;
        [self.navigationController pushViewController:geVC animated:YES];
   
    }else if(tableView == self.videoTableView)
    {
        
        LOLVideoXModel *model=self.videoModelArr[indexPath.row];

        [LSZNetWorkTools getWithUrl:VIDEODETAILURL(model.vid) parameter:nil httpHeader:nil resposeType:ResponseTypeJSON success:^(id result) {
            LOLmvplayerModel *urlModel =[[LOLmvplayerModel alloc]init];
                        [urlModel setValuesForKeysWithDictionary:result[@"result"][@"items"][@"350"][@"transcode"] ];


            LOLMvPlayerViewController *mvPlayer = [[LOLMvPlayerViewController alloc] init];
            mvPlayer.play_url = urlModel.url;
//            [self.navigationController pushViewController:mvPlayer animated:YES];
            [self presentViewController:mvPlayer animated:YES completion:^{
                
                
            }];
            
            
            
            
            
        } fail:^(NSError *error) {
            
            
        }];
        
    }
    else if(tableView==self.rightItemTableView)
    {
        
        self.rightItemTableView.hidden=YES;
        switch (indexPath.row) {
            case 0:
            {
                if(self.detailModel.name){
                    LOLWebViewController *webVC=[[LOLWebViewController alloc]init];
                    
                    webVC.url=HEROCOMMENTURL(self.detailModel.name);
                    [self.navigationController pushViewController:webVC animated:YES];
         
                }
            }
                
                break;
            case 1:
            {
                LOLimageViewController *IBVC=[[LOLimageViewController alloc]init];
                IBVC.enName = self.detailModel.name;
                IBVC.modalTransitionStyle = UIModalTransitionStyleCoverVertical ;
                
                [self presentViewController:IBVC animated:YES completion:nil];
             
            }
                break;
                
            case 2:
            {
                LOLversionViewController *versionVC=[[LOLversionViewController alloc]init];
                versionVC.enName=self.detailModel.name;
                [self.navigationController pushViewController:versionVC animated:YES];

            }
                break;
            case 3:
            {
               
            
            
            
            }
                break;
                
                
            default:
                break;
        }
        
        

  


}
}


-(void)pushToSelfPage:(NSNotification *)notifation
{

    for (LOLHeroModel *model  in self.modelArr) {
       
        if ([model.enName isEqualToString:notifation.userInfo[@"enName"]]) {
            
            
            LOLHerodetaiViewController *hdVC = [[LOLHerodetaiViewController alloc]init];
            hdVC.heroModel = model;
            [self.navigationController pushViewController:hdVC animated:YES];
            
            break;
        }
    }
    
    
    
}

-(void)clickDubTypeButton:(LOLBasebutton *)button
{
    if (button.tag == 311) {
        self.isHeroDub = YES;
        [button setTitleColor:[UIColor colorWithRed:0.260 green:0.797 blue:1.000 alpha:0.840] forState:UIControlStateNormal];
        [((UIButton *)[self.dubTableView viewWithTag:312])  setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
        
        self.dubNameArr = self.heroDubNameArr;
        [self.dubTableView reloadData];
        
        
    }
    else
    {
        self.isHeroDub = NO;
        [button setTitleColor:[UIColor colorWithRed:0.260 green:0.797 blue:1.000 alpha:0.840] forState:UIControlStateNormal];
        [((UIButton *)[self.dubTableView viewWithTag:311])  setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
        
        self.dubNameArr = self.otherDubNameArr;
        [self.dubTableView reloadData];
        
    }
    
    
}


-(void)createDubData
{
//    [YMH_AFNetworkTool getUrl:HERODUBNAMEURL(self.heroModel.enName) body:nil result:YMHJSON headerFile:nil success:^(id result) {
//        
//        self.heroDubNameArr = result;
//        self.dubNameArr = result;
//        self.isHeroDub = YES;
//        [self.dubTableView reloadData];
//        
//    } failure:^(NSError *error) {
//        
//    }];
//    [YMH_AFNetworkTool getUrl:OTHERDUBNameURL body:nil result:YMHJSON headerFile:nil success:^(id result) {
//        self.otherDubNameArr = result;
//        [self.dubTableView reloadData];
//        
//    } failure:^(NSError *error) {
//        
//    }];
    
    [LSZNetWorkTools getWithUrl:HERODUBNAMEURL(self.heroModel.enName) parameter:nil httpHeader:nil resposeType:nil success:^(id result) {
        NSLog(@"------%@",self.heroModel.enName);
        self.heroDubNameArr = result;
                self.dubNameArr = result;
                self.isHeroDub = YES;
                [self.dubTableView reloadData];
                

        
    } fail:^(NSError *error) {
        
        
    }];
    
    [LSZNetWorkTools getWithUrl:OTHERDUBNameURL parameter:nil httpHeader:nil resposeType:ResponseTypeJSON success:^(id result) {
        self.otherDubNameArr = result;
        [self.dubTableView reloadData];
        
    } fail:^(NSError *error) {
        
        
    }];
    
    
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
